<template>
	<view class="user-info-show">
		<view class="list">
			<view class="item" v-for="(item,index) in labelList" :key="index">
				<view class="label">
					{{item.name}}
				</view>
				<view class="info">
					<view class="img-holder" v-if="item.key=='icon'">
						<image :src="userInfo.icon"></image>
					</view>
					<input v-else type="text" v-model="userInfo[item.key]" />
				</view>
			</view>
		</view>

		<view class="btn" @tap="logout">
			退出登录
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				labelList: [{
					name: '头像',
					key: 'icon'
				}, {
					name: '用户名',
					key: 'username'
				}, {
					name: '昵称',
					key: 'nickname'
				}, {
					name: '手机号',
					key: 'phone'
				}]
			}
		},
		methods: {
			logout() {
				uni.removeStorageSync('token');
				uni.navigateTo({
					url: '/pages/user/login/login'
				})
			}
		},
		computed: {
			userInfo() {
				return this.$store.state.userInfo;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.user-info-show {
		.list {
			margin-top: 40rpx;
			width: 100%;

			.item {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 20rpx 0;
				width: 100%;
				border-bottom: 1px solid #e5e5e5;

				.label {
					line-height: 94rpx;
					font-size: 32rpx;
					color: #494949;
				}

				.info {
					line-height: 94rpx;
					font-size: 32rpx;
					color: #a1a1a1;
					display: flex;
					align-items: center;
					text-align: right;

					.img-holder {
						width: 120rpx;
						height: 120rpx;
						border-radius: 50%;
						overflow: hidden;
					}

					image {
						width: 100%;
						height: 100%;
					}
				}
			}
		}

		.btn {
			position: fixed;
			left: 50%;
			bottom: 20%;
			margin-left: -184rpx;
			width: 370rpx;
			height: 88rpx;
			font-size: 32rpx;
			color: #fff;
			text-align: center;
			line-height: 88rpx;
			background: #1c4b47;
			border-radius: 16rpx;
		}
	}
</style>
